#ifndef CUBE_MEMCHECK_H
#define CUBE_MEMCHECK_H

enum dtype_mem_check
{
	TYPE(MEM_CHECK)=0x4300,
};

enum subtype_mem_check
{
	SUBTYPE(MEM_CHECK,ROOT_STRUCT)=0x01,
	SUBTYPE(MEM_CHECK,ROOT_ADDRESS),
	SUBTYPE(MEM_CHECK,TEMP_MEM_SYS),
	SUBTYPE(MEM_CHECK,PAGE_TABLE),
	SUBTYPE(MEM_CHECK,FREE_MEM_SYS),
	SUBTYPE(MEM_CHECK,STATIC_SYS),
	SUBTYPE(MEM_CHECK,CACHE_SYS),
	SUBTYPE(MEM_CHECK,DMEM_SYS),
	SUBTYPE(MEM_CHECK,BUDDY_STRUCT),
	SUBTYPE(MEM_CHECK,NUM_CHECK)
};

typedef struct memcheck_root_struct
{
	UINT16 bottom;
	UINT16 upper;
	UINT32 total_size;
	UINT32 pagetable_size;
	UINT32 static_size;
	UINT32 occupy_size;
	UINT16 page_num;
	UINT16 fixed_pages;
	UINT16 empty_pages;
	UINT16 temp_pages;
}__attribute__((packed)) RECORD(MEM_CHECK,ROOT_STRUCT);

typedef struct memcheck_root_address
{
	UINT16 temp_area;
        UINT16 page_table;
        UINT16 free_area;
        UINT16 static_area;
        UINT16 cache_area;
        UINT16 dynamic_area;
}__attribute__((packed)) RECORD(MEM_CHECK,ROOT_ADDRESS);
typedef struct memcheck_temp_mem_sys
{
	UINT32 order;
        UINT32 size;
        UINT32 freelist;
        UINT32 pool;
}__attribute__((packed)) RECORD(MEM_CHECK,TEMP_MEM_SYS);
typedef struct memcheck_page_table
{
	UINT32 size;
        UINT32 start;
        UINT32 end;
}__attribute__((packed)) RECORD(MEM_CHECK,PAGE_TABLE);
typedef struct memcheck_free_mem_sys
{
	UINT16 page_num;
	UINT16 first_page;
}__attribute__((packed)) RECORD(MEM_CHECK,FREE_MEM_SYS);
typedef struct memcheck_static_sys
{
	UINT32 total_size;
        UINT16 pages_num;
        UINT16 first_page;
        UINT16 curr_page;
        UINT16 curr_offset;
}__attribute__((packed)) RECORD(MEM_CHECK,STATIC_SYS);
typedef struct memcheck_cache_sys
{
	UINT16 pages_num; 
        BYTE   index_limit;  
        UINT16 index_offset; 
        UINT16 index_num;    
        UINT32 total_size;UINT16 temp_pages;
}__attribute__((packed)) RECORD(MEM_CHECK,CACHE_SYS);
typedef struct memcheck_dmem_sys
{
	UINT32 total_size;  
        UINT16 pages_num;  
        UINT16 first_page; 
        UINT16 curr_page; 
        UINT16 curr_offset; 
        UINT32 half_stone;   
        UINT32 quad_stone;   
}__attribute__((packed)) RECORD(MEM_CHECK,DMEM_SYS);
typedef struct memcheck_buddy_struct
{
	UINT32 order;
	UINT32 poolsize;
	void ** freelist;
	UINT32 free_size;
	UINT32 reserved;
	void * pool;
}__attribute__((packed)) RECORD(MEM_CHECK,BUDDY_STRUCT);
typedef struct memcheck_num_check
{
	int memdb_num;
	int record_num;
}__attribute__((packed)) RECORD(MEM_CHECK,NUM_CHECK);
#endif
